{% extends "email/base.html" %}
{% load comments %}
{% block title %}Notifications for {{ test_list_instance.test_list.name }}{% endblock %}
{% block preheader %}Notifications for {{ test_list_instance.test_list.name }}{% endblock %}
{% block content %}
<p>Hello,</p>
<p>
  {% if notice_type == "follow_up" %}
    This is a follow up notice for the following Test List which
    was completed {{ test_list_instance.work_completed | timesince }} ago.
  {% elif notice_type == "completed" %}
    {% if failing_tests or tolerance_tests %}
      You are receiving this notice because one or more
      tests were at tolerance or action levels for the
      following test list instance:
    {% else %}
      You are receiving this notice because the following test
      list was just completed.
    {% endif %}
  {% endif %}
</p>
<table>
  <tr>
    <th class="header">
      Test List:
    </th>
    <td>
      {{test_list_instance.test_list.name}}
    </td>
  </tr>
  <tr>
    <th class="header">
      Unit:
    </th>
    <td>
      {{test_list_instance.unit_test_collection.unit.name}}
    </td>
  </tr>
  <tr>
    <th class="header">
      Date:
    </th>
    <td>
      {{ test_list_instance.work_completed }}
    </td>
  </tr>
  <tr>
    <th class="header">
      Link:
    </th>
    <td>
        <a href="{% if 'http' not in domain %}http://{% endif %}{{ domain }}{{ test_list_instance.get_absolute_url }}"
          title="Click to view on the site"
        >
          {% if 'http' not in domain %}http://{% endif %}{{ domain }}{{ test_list_instance.get_absolute_url }}
        </a>
    </td>
  </tr>
  {% if test_list_instance.comments.exists %}
    <tr>
      <th class="header">Comments:</th>
      <td>
        {% render_comment_list for test_list_instance %}
      </td>
    </tr>
  {% endif %}
</table>
{% if failing_tests %}
  <table class="test-table">
    <thead>
      <tr>
        <th class="action" colspan="4">
          Failing Tests
        </th>
      </tr>
      <tr>
        <th class="test">Test</th>
        <th class="value">Value</th>
        <th class="value">Reference</th>
        <th class="value">Tolerance</th>
      </tr>
    </thead>
    <tbody>
      {% for test_instance in failing_tests %}
        <tr>
          <td class="test">{{test_instance.unit_test_info.test}}</td>
          <td class="value">{{test_instance.value_display}}</td>
          <td class="value">{{test_instance.reference}}</td>
          <td class="value">{{test_instance.tolerance}}</td>
        </tr>
        {% if test_instance.comment %}
          <tr>
            <td class="comment" colspan="4">
              {{ test_instance.comment }}
            </td>
          </tr>
        {% endif %}
      {% endfor %}
    </tbody>
  </table>
{% endif %}
{% if tolerance_tests %}
  <table class="test-table">
    <thead>
      <tr>
        <th class="tolerance" colspan="4">
          Tests at Tolerance
        </th>
      </tr>
      <tr>
        <th class="test">Test</th>
        <th class="value">Value</th>
        <th class="value">Reference</th>
        <th class="value">Tolerance</th>
      </tr>
    </thead>
    <tbody>
      {% for test_instance in tolerance_tests %}
        <tr>
          <td class="test">{{test_instance.unit_test_info.test}}</td>
          <td class="value">{{test_instance.value_display}}</td>
          <td class="value">{{test_instance.reference}}</td>
          <td class="value">{{test_instance.tolerance}}</td>
        </tr>
        {% if test_instance.comment %}
          <tr>
            <td class="comment" colspan="4">
              {{ test_instance.comment }}
            </td>
          </tr>
        {% endif %}
      {% endfor %}
    </tbody>
  </table>
{% endif %}
{% endblock content %}

